#ifndef NCC_TRACK_H_
#define NCC_TRACK_H_

#include <QDebug>

void achieveTemplate(unsigned char *pSrc,unsigned char *pDst,int img_width,int img_height,int tmp_width,int tmp_height,unsigned short col,unsigned short row);
int crossCorr(unsigned char* img,unsigned char *templ,int *corr,int searchWidth,int searchHeight);
void integral(int searchWidth,int searchHeight);
void variance(float *mean,float *var);
float matchTemplate(int *newRow,int *newCol,int imgWidth,int imgHeight,int searchWidth,int searchHeight);
int TempThreshold(unsigned char *pSrc,int	srcWidth,int srcHeight,float *srcAvr,float *srcSigma);
void init_NCC();
void Init_Addr(void);
void TrackInit(unsigned short *x,unsigned short *y);
void setNCCImagePtr(unsigned char *img);
void setNCCTemplPtr(unsigned char *img,int width,int height);
int RectThreshold(unsigned char *pSrc,int srcWidth,int srcHeight,int top,int bottom,int left,int right,float *srcAvr,float *srcSigma);
float MatchUsingNCC(int *newRow,int *newCol,int imgWidth,int imgHeight,int searchWidth,int searchHeight);
void NCCScale(const unsigned char*  pSrc1,const unsigned char*  pSrc2,unsigned char *  pDst1,unsigned char *  pDst2,int srcWidth,	int srcHeight,int tmpWidth,	int tmpHeight);
void ImageScale(unsigned char  *pSrc,unsigned char  *pDst,int srcWidth,int srcHeight);
float FullScreenNCC(int *newRow,int *newCol,int imgWidth,int imgHeight);
void updateNCCPos(int row,int col);
float getNewPos(int *row,int *col);
float avr_constantf(float *array,int length);
float TrackTarget(unsigned char *pSrc,unsigned char *pTmp,unsigned char *pBuf,	int img_width,int img_height,int tmp_width,int tmp_height,	unsigned short *x,unsigned short *y);
void TrackLevel(int level);
void GetSubImage(unsigned char *pSrc,unsigned char *pDst,int imgWidth,int imgHeight,	unsigned short subimgWidth,unsigned short subimgHeight,unsigned short col,unsigned short row);
//void RunLengthDetect();
//void AutoTarDetect(unsigned short StartRow,unsigned short EndRow,unsigned short StartCol,unsigned short EndCol);
//void Maxarea_target();

////////////////////////////////////////////////////////////////////////////////////////////
//图像缩放函数
//Author:LongTao
////////////////////////////////////////////////////////////////////////////////////////////
unsigned char* MobanPixelZoom(
    unsigned char *pSrc,	//输入图像数据
    unsigned char *pDst,	//输出图像数据
    unsigned int srcWidth,	//输入图像宽度
    unsigned int srcHeight,	//输入图像高度
    unsigned int dstWidth,	//输出图像宽度
    unsigned int dstHeight);
//图像缩小，宽度扩大倍，高度扩大2倍
void ImageScale_x2(
    unsigned char  *pSrc,	//输入图像数据
    unsigned char  *pDst,	//输出图像数据
    int srcWidth,			//图像宽度
    int srcHeight);			//图像高度

void myResize(const unsigned char *dataSrc, unsigned char *dataDst, int src_width, int src_height, int width, int height);
//float matchTemplate(int *newRow,    //目标坐标y
//        int *newCol,                //目标坐标x
//        int imgWidth,               //图像宽
//        int imgHeight,              //图像高
//        unsigned char* tempimg,     //模板
//        int tempWidth,              //模板宽
//        int tempHeight,             //模板高
//        int searchWidth,            //搜索区宽
//        int searchHeight);           //搜索区高
//void integral(unsigned char* img, int searchWidth,int searchHeight);
//void variance(float *mean,float *var, unsigned char* temp_img);
#endif
